﻿Imports System.Data.Linq
Imports System.Linq

Public Class DemDetRepository
    Private dc As New TanNamChinhDataContext

    Public Sub New()
        dc = GeneralClassDAL.dc
    End Sub

    Public Function SelectAllRecord() As IQueryable(Of tblDemDet)
        Dim query = From p In dc.tblDemDets
                        Where p.IsActive = True
                        Select p
        Return query
    End Function

    Public Function SelectRecordById(ByVal id As Integer) As tblDemDet
        Return dc.tblDemDets.SingleOrDefault(Function(p As tblDemDet) p.ID_DemDet = id)
    End Function

    Public Sub Insert(ByVal obj As tblDemDet)
        dc.tblDemDets.InsertOnSubmit(obj)
        dc.SubmitChanges()
    End Sub

    Public Sub Update(ByVal obj As tblDemDet)
        dc.Refresh(RefreshMode.KeepChanges, obj)
        dc.SubmitChanges(ConflictMode.ContinueOnConflict)
    End Sub

    
End Class
